package pe.edu.ulima.movil;

import com.actionbarsherlock.app.SherlockActivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebFacebook extends SherlockActivity {

	private WebView webView;

	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		
		this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
		setContentView(R.layout.menu_principal_sitio_web);

		getWindow().setFeatureInt(	Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); 
		
		webView = (WebView) findViewById(R.id.wvwSitioWeb);
		webView.getSettings().setLoadWithOverviewMode(true);
		webView.getSettings().setUseWideViewPort(true);
		webView.getSettings().setBuiltInZoomControls(true);
		
		webView.setWebViewClient(new WebFacebook.WebFacebookWebViewClient());
		webView.getSettings().setJavaScriptEnabled(true);

		webView.loadUrl("http://www.facebook.com/ulima.pe");

	    final Activity MyActivity = this;
	    webView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress)   
        {
        	MyActivity.setTitle("Cargando...");
        	MyActivity.setProgress(progress * 100);
        	//
            if(progress == 100)
            	MyActivity.setTitle(R.string.sitio_web);
          }
        });
	}
	
	private class WebFacebookWebViewClient extends WebViewClient {
	    @Override
	    public boolean shouldOverrideUrlLoading(WebView view, String url) {
	        view.loadUrl(url);
	        return true;
	    }
	}
	
	
}
